package com.rrd.dw.mr.gzip.kafka;

import com.ucredit.babel.common.model.BaseModel;
import com.ucredit.babel.common.model.RecordType;
import com.ucredit.babel.common.model.third.baihang.BaihangBHWY023ARecord;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper.Context;

import java.io.IOException;

/**
 * 微言客群分-消费分拍平表
 *
 * @author guoqiang
 */

public class BaihangBHWY023AParse extends ParseBase {
    private Text val = new Text();
    private Text key = new Text();

    /**
     * 微言客群分-消费分拍平表
     *
     * @param model
     * @throws IOException
     * @throws InterruptedException
     */
    @Override
    public boolean parseJob(Context context, BaseModel<?> model, String successful) throws IOException, InterruptedException {
        BaihangBHWY023ARecord obj = (BaihangBHWY023ARecord) model;
        StringBuilder sb = getBaseInfo(obj, successful);

        StringBuilder TxSb = new StringBuilder(500);
		TxSb.append(formatValue(obj.getName())).append(CRT001);
		TxSb.append(formatValue(obj.getResponseCode())).append(CRT001);
		TxSb.append(formatValue(obj.getResponseMsg())).append(CRT001);
		TxSb.append(formatValue(obj.getGxpTxpf())).append(CRT001);
        StringBuilder txSb = getBaseInfo(obj);
        key.set(getKey());
        val.set((sb.toString() + TxSb + txSb.toString()).replace("\n", " ").replace("\r", " "));
        context.write(key, val);
        return true;
    }

    @Override
    public String getTableName() {
        return "kafka_babel_baihang_bhwy023_a_inc";
    }

    @Override
    public String getType() {
        return RecordType.BAIHANG_BHWY023A_RECORD.toString();
    }

    @Override
    public String getComment() {
        return "微言客群分-消费分拍平表";
    }
}
